import React, { Component } from 'react';
import { connect } from 'react-redux';

function mapStateToProps(state) {
    return {
     ...state
    };
}

function mapDispatchToProps(dispatch) {
    return {
        selectCatory(key){
            dispatch({type:"SELECT_CATEGORY",data:key})
        }

    };
}

class Category extends Component {
    render() {
        let {category}=this.props;
        return (
            <div className="category">
                 {category.map((v,i)=>{
                       return <div key={i} className="item" onClick={()=>{
                             this.props.selectCatory(v)
                       }}>{v}</div>
                     })}
            </div>
        )
    }
}

export default connect(
    mapStateToProps,mapDispatchToProps
)(Category);